/**
 * Created by kangmengmeng on 2016/12/06 11:00;
 */
var vm = new Vue({
	el : '#main',
	data : {
		role : {
			roleNo : App.getParam("roleNo")
		},
		roleTypes:[],
	    agentCates:[]
	},
	created : function() {
		this.queryRolesType();
        this.queryAgentCate();
		
	},
	methods : {
		// 返回上一页的点击事件的函数
		goBtn : function() {
			// 不保留
			history.back(-1);
			// 保留
			// history.go(-1);
		},
		queryRolesType:function(){
        	App.ajax({
    			type:"GET",
    			url:App.getApiUrl("queryRolesTypeURL"),
    			success:function(data){
    				vm.roleTypes = data;
				}
			});
        },
        queryAgentCate:function(){
        	App.ajax({
    			type:"GET",
    			url:App.getApiUrl("queryAgentCateURL"),
    			success:function(data){
    				vm.agentCates = data;
    				vm.queryRolesInfo();
				}
			});
        },
		queryRolesInfo:function(){
			App.ajax({
				type:"GET",
				url:App.getApiUrl("getRolesInfoURL") + "?roleNo=" + this.role.roleNo,
				success:function(data){
					vm.role = data;
					setTimeout(function(){
						selectSet("roleType",data.roleType);
						selectSet("agentCate",data.agentCate);
					}, 1);
				}
			});
		},
		saveRole : function() {
			App.ajax({
				type:"POST",
				url:App.getApiUrl("modifyRolesURL"),
				data : vm.role,
				success:function(data){
					parent.showAlert(data.msg);
				}
			});
		}
	}
});